1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module gtk.HeaderBar;
26 
27 private import glib.ConstructionException;
28 private import glib.Str;
29 private import glib.c.functions;
30 private import gobject.ObjectG;
31 private import gtk.Widget;
32 private import gtk.c.functions;
33 public  import gtk.c.types;
34 
35 
36 /**
37  * `GtkHeaderBar` is a widget for creating custom title bars for windows.
38  * 
39  * ![An example GtkHeaderBar](headerbar.png)
40  * 
41  * `GtkHeaderBar` is similar to a horizontal `GtkCenterBox`. It allows
42  * children to be placed at the start or the end. In addition, it allows
43  * the window title to be displayed. The title will be centered with respect
44  * to the width of the box, even if the children at either side take up
45  * different amounts of space.
46  * 
47  * `GtkHeaderBar` can add typical window frame controls, such as minimize,
48  * maximize and close buttons, or the window icon.
49  * 
50  * For these reasons, `GtkHeaderBar` is the natural choice for use as the
51  * custom titlebar widget of a `GtkWindow` (see [method@Gtk.Window.set_titlebar]),
52  * as it gives features typical of titlebars while allowing the addition of
53  * child widgets.
54  * 
55  * ## GtkHeaderBar as GtkBuildable
56  * 
57  * The `GtkHeaderBar` implementation of the `GtkBuildable` interface supports
58  * adding children at the start or end sides by specifying “start” or “end” as
59  * the “type” attribute of a <child> element, or setting the title widget by
60  * specifying “title” value.
61  * 
62  * By default the `GtkHeaderBar` uses a `GtkLabel` displaying the title of the
63  * window it is contained in as the title widget, equivalent to the following
64  * UI definition:
65  * 
66  * ```xml
67  * <object class="GtkHeaderBar">
68  * <property name="title-widget">
69  * <object class="GtkLabel">
70  * <property name="label" translatable="yes">Label</property>
71  * <property name="single-line-mode">True</property>
72  * <property name="ellipsize">end</property>
73  * <property name="width-chars">5</property>
74  * <style>
75  * <class name="title"/>
76  * </style>
77  * </object>
78  * </property>
79  * </object>
80  * ```
81  * 
82  * # CSS nodes
83  * 
84  * ```
85  * headerbar
86  * ╰── windowhandle
87  * ╰── box
88  * ├── box.start
89  * │   ├── windowcontrols.start
90  * │   ╰── [other children]
91  * ├── [Title Widget]
92  * ╰── box.end
93  * ├── [other children]
94  * ╰── windowcontrols.end
95  * ```
96  * 
97  * A `GtkHeaderBar`'s CSS node is called `headerbar`. It contains a `windowhandle`
98  * subnode, which contains a `box` subnode, which contains two `box` subnodes at
99  * the start and end of the header bar, as well as a center node that represents
100  * the title.
101  * 
102  * Each of the boxes contains a `windowcontrols` subnode, see
103  * [class@Gtk.WindowControls] for details, as well as other children.
104  * 
105  * # Accessibility
106  * 
107  * `GtkHeaderBar` uses the %GTK_ACCESSIBLE_ROLE_GROUP role.
108  */
109 public class HeaderBar : Widget
110 {
111 	/** the main Gtk struct */
112 	protected GtkHeaderBar* gtkHeaderBar;
113 
114 	/** Get the main Gtk struct */
115 	public GtkHeaderBar* getHeaderBarStruct(bool transferOwnership = false)
116 	{
117 		if (transferOwnership)
118 			ownedRef = false;
119 		return gtkHeaderBar;
120 	}
121 
122 	/** the main Gtk struct as a void* */
123 	protected override void* getStruct()
124 	{
125 		return cast(void*)gtkHeaderBar;
126 	}
127 
128 	/**
129 	 * Sets our main struct and passes it to the parent class.
130 	 */
131 	public this (GtkHeaderBar* gtkHeaderBar, bool ownedRef = false)
132 	{
133 		this.gtkHeaderBar = gtkHeaderBar;
134 		super(cast(GtkWidget*)gtkHeaderBar, ownedRef);
135 	}
136 
137 
138 	/** */
139 	public static GType getType()
140 	{
141 		return gtk_header_bar_get_type();
142 	}
143 
144 	/**
145 	 * Creates a new `GtkHeaderBar` widget.
146 	 *
147 	 * Returns: a new `GtkHeaderBar`
148 	 *
149 	 * Throws: ConstructionException GTK+ fails to create the object.
150 	 */
151 	public this()
152 	{
153 		auto __p = gtk_header_bar_new();
154 
155 		if(__p is null)
156 		{
157 			throw new ConstructionException("null returned by new");
158 		}
159 
160 		this(cast(GtkHeaderBar*) __p);
161 	}
162 
163 	/**
164 	 * Gets the decoration layout of the `GtkHeaderBar`.
165 	 *
166 	 * Returns: the decoration layout
167 	 */
168 	public string getDecorationLayout()
169 	{
170 		return Str.toString(gtk_header_bar_get_decoration_layout(gtkHeaderBar));
171 	}
172 
173 	/**
174 	 * Returns whether this header bar shows the standard window
175 	 * title buttons.
176 	 *
177 	 * Returns: %TRUE if title buttons are shown
178 	 */
179 	public bool getShowTitleButtons()
180 	{
181 		return gtk_header_bar_get_show_title_buttons(gtkHeaderBar) != 0;
182 	}
183 
184 	/**
185 	 * Retrieves the title widget of the header.
186 	 *
187 	 * See [method@Gtk.HeaderBar.set_title_widget].
188 	 *
189 	 * Returns: the title widget of the header
190 	 */
191 	public Widget getTitleWidget()
192 	{
193 		auto __p = gtk_header_bar_get_title_widget(gtkHeaderBar);
194 
195 		if(__p is null)
196 		{
197 			return null;
198 		}
199 
200 		return ObjectG.getDObject!(Widget)(cast(GtkWidget*) __p);
201 	}
202 
203 	/**
204 	 * Adds @child to @bar, packed with reference to the
205 	 * end of the @bar.
206 	 *
207 	 * Params:
208 	 *     child = the `GtkWidget` to be added to @bar
209 	 */
210 	public void packEnd(Widget child)
211 	{
212 		gtk_header_bar_pack_end(gtkHeaderBar, (child is null) ? null : child.getWidgetStruct());
213 	}
214 
215 	/**
216 	 * Adds @child to @bar, packed with reference to the
217 	 * start of the @bar.
218 	 *
219 	 * Params:
220 	 *     child = the `GtkWidget` to be added to @bar
221 	 */
222 	public void packStart(Widget child)
223 	{
224 		gtk_header_bar_pack_start(gtkHeaderBar, (child is null) ? null : child.getWidgetStruct());
225 	}
226 
227 	/**
228 	 * Removes a child from the `GtkHeaderBar`.
229 	 *
230 	 * The child must have been added with
231 	 * [method@Gtk.HeaderBar.pack_start],
232 	 * [method@Gtk.HeaderBar.pack_end] or
233 	 * [method@Gtk.HeaderBar.set_title_widget].
234 	 *
235 	 * Params:
236 	 *     child = the child to remove
237 	 */
238 	public void remove(Widget child)
239 	{
240 		gtk_header_bar_remove(gtkHeaderBar, (child is null) ? null : child.getWidgetStruct());
241 	}
242 
243 	/**
244 	 * Sets the decoration layout for this header bar.
245 	 *
246 	 * This property overrides the
247 	 * [property@Gtk.Settings:gtk-decoration-layout] setting.
248 	 *
249 	 * There can be valid reasons for overriding the setting, such
250 	 * as a header bar design that does not allow for buttons to take
251 	 * room on the right, or only offers room for a single close button.
252 	 * Split header bars are another example for overriding the setting.
253 	 *
254 	 * The format of the string is button names, separated by commas.
255 	 * A colon separates the buttons that should appear on the left
256 	 * from those on the right. Recognized button names are minimize,
257 	 * maximize, close and icon (the window icon).
258 	 *
259 	 * For example, “icon:minimize,maximize,close” specifies a icon
260 	 * on the left, and minimize, maximize and close buttons on the right.
261 	 *
262 	 * Params:
263 	 *     layout = a decoration layout, or %NULL to unset the layout
264 	 */
265 	public void setDecorationLayout(string layout)
266 	{
267 		gtk_header_bar_set_decoration_layout(gtkHeaderBar, Str.toStringz(layout));
268 	}
269 
270 	/**
271 	 * Sets whether this header bar shows the standard window
272 	 * title buttons.
273 	 *
274 	 * Params:
275 	 *     setting = %TRUE to show standard title buttons
276 	 */
277 	public void setShowTitleButtons(bool setting)
278 	{
279 		gtk_header_bar_set_show_title_buttons(gtkHeaderBar, setting);
280 	}
281 
282 	/**
283 	 * Sets the title for the `GtkHeaderBar`.
284 	 *
285 	 * When set to %NULL, the headerbar will display the title of
286 	 * the window it is contained in.
287 	 *
288 	 * The title should help a user identify the current view.
289 	 * To achieve the same style as the builtin title, use the
290 	 * “title” style class.
291 	 *
292 	 * You should set the title widget to %NULL, for the window
293 	 * title label to be visible again.
294 	 *
295 	 * Params:
296 	 *     titleWidget = a widget to use for a title
297 	 */
298 	public void setTitleWidget(Widget titleWidget)
299 	{
300 		gtk_header_bar_set_title_widget(gtkHeaderBar, (titleWidget is null) ? null : titleWidget.getWidgetStruct());
301 	}
302 }